﻿@model HMS.Web.Helpers.Clinic
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    if (Session["Clinic"] != null)
    {
        HMS.Web.Helpers.Clinic clinic = new HMS.Web.Helpers.Clinic();
        clinic = (HMS.Web.Helpers.Clinic)Session["Clinic"];
        ViewBag.Title = clinic.Name;
    }
    else
  {
    ViewBag.Title = Model.Name;
    }
}

    <main id="mainPanel">
        <section class="container">
            <div class="text-center panel" id="picPanel">
                <h1>@Model.Name</h1>
                <h3><a href="tel:@Model.Phone">CALL:@Model.Phone</a></h3>
                @*<p><a href="#" onclick="menuClick(this);" class="btn btn-default btn-large btn-primary">Appointments</a></p>*@
                <p><a href="/Appointment/EditAppointment" class="btn btn-default btn-large btn-primary">Book Appointment</a></p>
                 <input placeholder="Log In" id="accessCode" style="padding:5px;" /> 
                
                            <a href="javascript:void(0)" class="btn btn-default btn-large btn-primary" id="logIn">Go</a>
                <p id="loginError" class="hide" style="color:red;margin-left:7px;">Invalid user. Please enter valid access code.</p>
                @*<div class=" ">
                    <a href="#"><h1>@Model.Name</h1></a>
                    <h2>Eu Tellus Fermentun Vehicula</h2>
                    <ul class="banner_btn">
                        
                        <li class="yellow">
                               
                        </li>
                        <li class="grey"><a >Book Appointment</a></li>
                        
                    </ul>
                    
                </div>*@
            </div>
        </section>
        <section class="container">
            <div class="well">
                <h2>Welcome</h2>
                <p class="lead">All that is good begins with a SMILE</p><p>
                    <br/>
                        When you visit our office, your smile is our top priority.  Our entire team is dedicated to providing you with the personalized, gentle care that you deserve.
                </p>
                <br/>
                    <p>Part of our commitment to serving our patients involves providing information that helps them to make more informed decisions about their oral health needs.  This website is a resource we hope you'll find both useful and interesting.</p>
                    <!--p class="text-center"><a class="btn" href="index.html">Read more</a></p-->
            </div>

        </section>
    </main>
<input type="hidden" id="clinicCode" value="@Model.Code" />
    <script type="text/javascript">
        localStorage.setItem("ClinicName",'@Model.Name');
        localStorage.setItem("ClinicPhone", '@Model.Phone'); 
        localStorage.setItem("DoctorLocId", "");
        localStorage.setItem("ClinicCode", '@Model.Code');
        //$(document).ready(function () {
        //    $("#ClinicName").html(_ClinicName + " " + "<a id='ClinicNumber' href='tel:" + _ClinicPhone + "'><span class='glyphicon glyphicon-earphone' id='ClinicPhoneSpan'></span>" + _ClinicPhone + "</a>");
            
        //});
        $("#logIn").click(function () {
            if ($("#accessCode").val()) {
                if ($("#accessCode").val().split("-").length === 3 && $("#accessCode").val().split("-")[0].toUpperCase() == $("#clinicCode").val()) {
                    $("#loginError").addClass("hide");
                    $.ajax({
                        type: "POST",
                        url: _AbsolutePath + 'User/ValidateUser',
                        contentType: "application/json",
                        data: JSON.stringify({ accessCode: $("#accessCode").val() }),
                        caller: arguments.callee.name,//gets currently running function name
                        dataType: "json", //Cross domain call (even json also work)
                        success: function (res) {
                            if (res.Id > 0) {
                                if (res.Detail === "D")
                                    location.href = "/Appointment/AppoinmentIndex";
                                else
                                    location.href = "/Patient/Index";
                            }
                            else {
                                $("#loginError").removeClass("hide");
                            }
                        },
                        error: function (xhr) { debugger; }
                    });
                }
                else {
                    $("#loginError").removeClass("hide");
                }
            }
        });

    </script>